package com.hzncc.scaffold.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.hzncc.scaffold.entity.Bo.MyInvigilationBo;
import com.hzncc.scaffold.entity.Other.Oneplusxtraining;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hzncc.scaffold.entity.Vo.OnePlusXTrainingListVo;
import com.hzncc.scaffold.entity.Bo.TrainingDetailBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 1+X练习表 Mapper 接口
 * </p>
 *
 * @author DrunkBear
 * @since 2022-04-27
 */
@Component
public interface OneplusxtrainingMapper extends BaseMapper<Oneplusxtraining> {


    @Select("SELECT\n" +
            "\t* ,\n" +
            "\tattachFile As attachFileJson\n" +
            "FROM\n" +
            "\t`oneplusxtraining` ${ew.customSqlSegment}")
    public List<OnePlusXTrainingListVo> listVo(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);


    @Select("SELECT\n" +
            "\t`invigilatorconfirm`.`id`,\n" +
            "\t`invigilatorconfirm`.`title`,\n" +
            "\t`invigilatorconfirm`.`status`,\n" +
            "\t`oneplusxtraining`.`id` AS `onePlusXTrainingId`,\n" +
            "\t`oneplusxtraining`.`title` AS `onePlusXTrainingTitle`,\n" +
            "\t`oneplusxtraining`.`startTime` AS `startTime`,\n" +
            "\t`oneplusxtraining`.`endTime` AS `endTime` \n" +
            "FROM\n" +
            "\t`invigilatorconfirm` AS `invigilatorconfirm`\n" +
            "LEFT OUTER JOIN `oneplusxtraining` AS `oneplusxtraining` ON `invigilatorconfirm`.`examId` = `oneplusxtraining`.`id` ${ew.customSqlSegment}")
    public List<MyInvigilationBo> myInvigilation(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);


    @Select("SELECT\n" +
            "\t`oneplusxtraining`.`id`,\n" +
            "\t`oneplusxtraining`.`title`,\n" +
            "\t`oneplusxtraining`.`startTime`,\n" +
            "\t`oneplusxtraining`.`endTime`,\n" +
            "\t`oneplusxtraining`.`info`,\n" +
            "\t`oneplusxtraining`.`type`,\n" +
            "\t`oneplusxtraining`.`createTime`,\n" +
            "\t`oneplusxtraining`.`attachFile`,\n" +
            "\t`oneplusxtraining`.`activityStart`,\n" +
            "\t`oneplusxtraining`.`activityEnd`,\n" +
            "\t`oneplusxtraining`.`certNumPrefix`,\n" +
            "\t certnum.title AS certTitle,\n" +
            "\t certnum.certType,\n" +
            "\t certnum.`level`\n" +
            "FROM\n" +
            "\t`oneplusxtraining` AS `oneplusxtraining`\n" +
            "\tLEFT OUTER JOIN `invigilatorconfirm` AS `invigilatorconfirms` ON `oneplusxtraining`.`id` = `invigilatorconfirms`.`examId`\n " +
            "\tLEFT JOIN certnum ON certnum.prefix = oneplusxtraining.certNumPrefix ${ew.customSqlSegment}")
    public TrainingDetailBo trainingDetail(@Param(Constants.WRAPPER) QueryWrapper queryWrapper);
}
